<template>
    <el-container class="container">
        <el-header class="header">
            <el-row>
                <el-col :span="4">
                    <h1>假装有logo</h1>
                </el-col>
                <el-col :span="18">
                    <h1 style="text-align: center">电商后台管理系统</h1>
                </el-col>
                <el-col :span="2">
                    <div class="grid-content bg-purple">
                        <!-- prevent 修饰符,拦截默认事件 -->
                        <a
                            @click.prevent="out()"
                            href="#"
                            style="text-decoration: none; line-height: 60px"
                        >
                            退出
                        </a>
                    </div>
                </el-col>
            </el-row>
        </el-header>
        <el-container>
            <el-aside class="aside" width="200px">
                <!-- 开启路由模式                  -->
                <el-menu :router="true" :unique-opened="true">
                    <el-submenu index="1">
                        <template slot="title">
                            <i class="el-icon-location"></i>
                            <span>用户管理</span>
                        </template>
                        <!-- index值变成path值 -->
                        <el-menu-item index="users">
                            <i class="el-icon-success"></i>
                            <span>用户列表</span>
                        </el-menu-item>
                    </el-submenu>

                    <el-submenu index="2">
                        <template slot="title">
                            <i class="el-icon-location"></i>
                            <span>权限管理</span>
                        </template>
                        <el-menu-item index="role">
                            <i class="el-icon-success"></i>
                            <span>角色列表</span>
                        </el-menu-item>
                        <el-menu-item index="rights">
                            <i class="el-icon-success"></i>
                            <span>权限列表</span>
                        </el-menu-item>
                    </el-submenu>

                    <el-submenu index="3">
                        <template slot="title">
                            <i class="el-icon-location"></i>
                            <span>商品管理</span>
                        </template>
                        <el-menu-item index="goodslist">
                            <i class="el-icon-success"></i>
                            <span>商品列表</span>
                        </el-menu-item>
                        <el-menu-item index="goodscate">
                            <i class="el-icon-success"></i>
                            <span>商品分类</span>
                        </el-menu-item>
                    </el-submenu>

                    <el-submenu index="4">
                        <template slot="title">
                            <i class="el-icon-location"></i>
                            <span>订单管理</span>
                        </template>
                        <el-menu-item index="order">
                            <i class="el-icon-success"></i>
                            <span>订单列表</span>
                        </el-menu-item>
                    </el-submenu>

                    <el-submenu index="5">
                        <template slot="title">
                            <i class="el-icon-location"></i>
                            <span>数据统计</span>
                        </template>
                        <el-menu-item index="reports">
                            <i class="el-icon-success"></i>
                            <span>数据报表</span>
                        </el-menu-item>
                    </el-submenu>
                </el-menu>
            </el-aside>
            <el-main class="main">
                <!-- 在需要显示的容器里写router-view -->
                <router-view></router-view>
            </el-main>
        </el-container>
    </el-container>
</template>

<script>
export default {
    beforeCreate() {
        //获取token
        // const token = localStorage.getItem("token");
        // if (!token) {
        //     this.$router.push({ name: "login" });
        // }
    },
    methods: {
        out() {
            // 清除token
            localStorage.clear();
            this.$message.success("退出成功");
            this.$router.push({ name: "login" });
        },
    },
};
</script>
<style >
.container {
    height: 100%;
}
.header {
    background-color: #b3c0d1;
}
.aside {
    background-color: #d3dce6;
}
.main {
    background-color: #e9eef3;
}
</style>